<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace app\admin\model;

class Coupon extends \app\BaseModel
{
    protected $name = "longbing_card_coupon";
    protected $append = ["status_text", "type_text"];
    public function getStatusTextAttr($value, $data)
    {
        $status = ["18446744073709551615" => "已删除", "0" => "未发布", "1" => "已发布"];
        return $status[$data["status"]];
    }
    public function getTypeTextAttr($value, $data)
    {
        $type = ["1" => "线上", "2" => "线下"];
        return $type[$data["type"]];
    }
    public function getEndTimeAttr($value, $data)
    {
        return date("Y-m-d H:i:s", $data["end_time"]);
    }
    public function getCreateTimeAttr($value, $data)
    {
        return date("Y-m-d H:i:s", $data["create_time"]);
    }
    public function couponList($dis, $page = 10)
    {
        $data = self::where($dis)->order("top desc")->paginate($page)->toArray();
        return $data;
    }
    public function couponUpdate($dis, $data)
    {
        $data["update_time"] = time();
        $res = \think\facade\Db::name($this->name)->where($dis)->update($data);
        return $res;
    }
    public function couponAdd($data)
    {
        $data["create_time"] = time();
        $res = \think\facade\Db::name($this->name)->insert($data);
        return $res;
    }
    public function couponInfo($dis)
    {
        $data = \think\facade\Db::name($this->name)->where($dis)->find();
        return $data;
    }
}

?>